// packageB/member/distribution_queue/activity_details/activity_details.js
var app = getApp();
Page({

  /**
	 * 页面的初始数据
	 */
  data: {
    list:[],
    id:'',
    offset:0,
    limit:15,
    avatar:'',
    nickname:'',
    level_name:'',
    invite_code:'',
    count:0,
    begin_time:'',
    end_time:''
  },
  
  /**
	 * 生命周期函数--监听页面加载
	 */
  onLoad: function(options) {
    console.log(options)
    this.setData({
      id:options.id,
      begin_time:options.begin_time,
      end_time:options.end_time,
      invite_code:wx.getStorageSync("invite_code"),
      member_id:wx.getStorageSync("yz_uid"),
    })
    this.getInfo();
    this.getList()
  },
  getList(){
    let urlStr = app.getNetAddresss(`member.teamDividendStatistics.get-detail-by-shared-id&shared_id=${this.data.id}&offset=${this.data.offset}&limit=${this.data.limit}&begin_time=${this.data.begin_time}&end_time=${this.data.end_time}`);
    let that = this
    app._postNetWork({
      url: urlStr,
      showToastIn: false,
      data: {},
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          let list = [];
          list = that.data.list.concat(res.data.list);
          that.setData({
            list: list,
            count:res.data.count
          });
        } else {
          wx.showToast({
            icon: "none",
            title: res.msg,
            duration: 1500,
          });
        }
      },
      fail: function (res) {
        console.log(res.msg);
      },
    });
  },
  getInfo(){
    let that = this;
    let urlStr = app.getNetAddresss(`plugin.newcomer-fission.frontend.controllers.center.index`);
    app._postNetWork({
      url: urlStr,
      showToastIn: false,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            avatar:res.data.info.avatar,
            nickname:res.data.info.nickname,
            level_name:res.data.info.level_name,
            member_id:wx.getStorageSync("yz_uid"),
            invite_code:wx.getStorageSync("invite_code")
          })
        } else {
          wx.showToast({
            icon: "none",
            title: res.msg,
            duration: 1500,
          });
        }
      },
      fail: function (res) {
        console.log(res.msg);
      },
    });
   
  },

  /**
	 * 生命周期函数--监听页面初次渲染完成
	 */
  onReady: function() {
    let language = wx.getStorageSync('langIndex');
    this.setData({ 'language': language.en});
  },

  /**
	 * 生命周期函数--监听页面显示
	 */
  onShow: function() {

  },

  /**
	 * 生命周期函数--监听页面隐藏
	 */
  onHide: function() {

  },

  /**
	 * 生命周期函数--监听页面卸载
	 */
  onUnload: function() {

  },

  /**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
  onPullDownRefresh: function() {

  },

  /**
	 * 页面上拉触底事件的处理函数
	 */
  onReachBottom: function() {
    if(this.data.list.length >= this.data.count){
      return true;
    }
    this.setData({
      offset:this.data.offset+1
    })
    this.getList();
  },
  copybtn(e) {
    console.log(e)
    let inviteCode = e.target.dataset.num;
    wx.setClipboardData({
      data: inviteCode ? inviteCode : "",
      success(res) {
        wx.showToast({
          icon: "none",
          title: "复制成功",
          duration: 1000,
        });
      },
    });
  },

});
